import store from "../../../store";
import dealTree from './dealTree'
import deepClone from './deepClone'
import router from '../../../router'

const navigatorTo = ({url}) => {
  let path = url.split('/')
  path = path[path.length - 1]

  let routers = dealTree(deepClone(store.getters.menuList), node => node.url == path)
  if (routers.length) {
    store.commit('$uStore', {
      name: 'vuex_menu', value: routers[0]
    })

    router.push({path: url})
  }
}

export default navigatorTo
